package com.highspeed.bdk.controller.logic;


import com.bianmaba.spring.data.jpa.domain.Result;
import com.bianmaba.spring.mvc.method.support.annotations.JSON;
import com.highspeed.bdk.bean.entity.logic.LogicTopology;
import com.highspeed.bdk.controller.base.BdkCrudController;
import com.highspeed.bdk.service.base.IBdkBaseService;
import com.highspeed.bdk.service.logic.ILogicTopologyService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "logic_topology", method = RequestMethod.POST)
@Api(tags = "逻辑拓扑")
public class LogicTopologyController extends BdkCrudController<LogicTopology, Integer> {
    @Autowired
    private ILogicTopologyService logicTopologyService;

    @Override
    protected IBdkBaseService<LogicTopology, Integer> getService() {
        return logicTopologyService;
    }

    @ApiOperation(value = "保存整个逻辑拓扑图", notes = "参数为JSON数据;<br/>" +
            "数据中的链路信息不会被保存,需要单独调用logic_link\\save来保存;")
    @JSON
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @Override
    public Result save(@RequestBody @ApiParam(name = "entity") LogicTopology entity) {
        return super.save(entity);
    }

    @JSON
    @ApiOperation(value = "根据逻辑拓扑id查询虚线")
    @ApiImplicitParam(name = "id", value = "逻辑拓扑id", dataType = "int", paramType = "query")
    @RequestMapping({"/get_virtual_links_by_logic_topology_id"})
    public List<Map<String, Integer>> queryVirtualLinksByLogicTopologyId(Integer id) {
        return logicTopologyService.queryVirtualLinksByLogicTopologyId(id);
    }
}
